package com.lld.im.service.user.controller;

import com.lld.im.common.ResponseVO;
import com.lld.im.service.rpc.model.req.ZkUserInfoReq;
import com.lld.im.service.rpc.server.ZkRpcServer;
import com.lld.im.service.user.model.req.*;
import com.lld.im.service.user.service.ImUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: lld
 * @version: 1.0
 */

@RestController
@RequestMapping("v1/user")
public class ImUserDataController {

    private static Logger logger = LoggerFactory.getLogger(ImUserDataController.class);

    @Autowired
    ImUserService imUserService;



    @PostMapping("/getUserInfo")
    public ResponseVO getUserInfo(@RequestBody GetUserInfoReq req, Integer appId){//@Validated
        req.setAppId(appId);
        return imUserService.getUserInfo(req);
    }

    @PostMapping("/getSingleUserInfo")
    public ResponseVO getSingleUserInfo(@RequestBody @Validated UserId req, Integer appId){
        req.setAppId(appId);
        return imUserService.getSingleUserInfo(req.getUserId(),req.getAppId());
    }

    @PostMapping("/modifyUserInfo")
    public ResponseVO modifyUserInfo(@RequestBody @Validated ModifyUserInfoReq req, Integer appId){
        req.setAppId(appId);
        return imUserService.modifyUserInfo(req);
    }

    @Operation(description = "登录")
    @io.swagger.v3.oas.annotations.parameters.RequestBody(content = {

    })
    @PostMapping("/login")
    public ResponseVO login(@RequestBody @Validated LoginReq req, Integer appId){
        req.setAppId(appId);
        return imUserService.login(req);
    }

    @Operation(description = "注册")
    @PostMapping("/register")
    public ResponseVO registerUser(@RequestBody RegisterUserReq req, Integer appId){
        req.setAppId(appId);
        return imUserService.registerUser(req);
    }
}
